package com.xdf.ecommerce.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author chanchaw
 * @create 2025-10-14 9:52
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CommonResponse<T> implements Serializable {
    private Integer code;// 错误码，没有报错则为0
    private String message;
    private T data;
    // 成功响应数据同时设置其他2个属性
    public CommonResponse(T data){
        this.data = data;
        this.code = 0;
        this.message = "";
    }
    // 响应报错时清空返回数据
    public CommonResponse(Integer code,String msg){
        this.code = code;
        this.message = msg;
        this.data = null;
    }
}
